package review_demo4;

public class TestRevDemo4 {
    public static void running(IRun iRun) {
        iRun.run();
    }
    public static void swimming(ISwim iSwim) {
        iSwim.swim();
    }
    public static void flying(IFly iFly) {
        iFly.fly();
    }

    public static void main(String[] args) {
        Fish fish = new Fish("🐟");
        Bird bird = new Bird("🐦");
        Dog dog = new Dog("🐕");
        swimming(fish);
        swimming(bird);//如果都有 那么是不必用接口 直接放在Aniaml就可以
        swimming(dog);
        System.out.println("---------");
        running(bird);
        running(dog);
//        running(fish);//err
        System.out.println("---------");
        flying(bird);
    }
}

abstract class Animal {
    public String name;

    public Animal() {
    }

    public Animal(String name) {
        this.name = name;
    }
}

interface IRun {
    void run();
}

interface ISwim {
    void swim();
}

interface IFly {
    void fly();
}

class Dog extends Animal implements IRun,ISwim {
    public Dog(String name) {
        super(name);
    }

    @Override
    public void swim() {
        System.out.println(this.name + "在狗刨式游泳");
    }

    @Override
    public void run() {
        System.out.println(this.name + "在摇着尾巴跑");
    }
}

class Bird extends Animal implements IFly,ISwim,IRun {
    public Bird() {
        super();
    }

    public Bird(String name) {
        super(name);
    }

    @Override
    public void fly() {
        System.out.println(this.name + "在自由翱翔");
    }

    @Override
    public void swim() {
        System.out.println(this.name + "在潜泳");
    }

    @Override
    public void run() {
        System.out.println(this.name + "在迈着小脚快跑");
    }
}

class Fish extends Animal implements ISwim {
    public Fish(String name) {
        super(name);
    }

    @Override
    public void swim() {
        System.out.println(this.name + "在游泳");
    }
}